//
//  UIViewController+Login.swift
//  SitPosition
//
//  Created by apple on 2019/1/12.
//  Copyright © 2019 apple. All rights reserved.
//

import Foundation
import UIKit


extension UIViewController {
    
    // 显示登录页面
    // @return：YES 显示登录页面
    //          NO 没有显示登录页面
    @discardableResult
    func showLoginViewControllerIfNeeded(_ forceDisplayMode: Bool) -> Bool {
        guard !UserManager.manager.isLogin() else { return false }
        
        let loginVC = UserLoginViewController()
        let loginNav = UINavigationController(rootViewController: loginVC)
        loginVC.backCallback = { [weak self] in
            if forceDisplayMode {
                guard UserManager.manager.isLogin() else { return }
            }
            self?.dismiss(animated: true, completion: nil)
        }
        present(loginNav, animated: false, completion: nil)
        return true
    }
}
